<template>
  <s-modal title="详情" :visible="visible" width="800px" :footer="null" @cancel="visible = false">
    <div style="height: 400px">
      <s-scroll>
        <s-form ref="form" :value="formValue">
          <s-form-item label="父级部门">
            <s-select-tree
              v-model="formValue.parentId"
              disabled
              allow-clear
              url="/realm/dept/selectList"
              value-field="id"
              placeholder="父级部门"
            />
          </s-form-item>

          <s-form-item label="部门名称">
            <s-input v-model="formValue.text" disabled allow-clear placeholder="部门名称" />
          </s-form-item>
          <s-form-item label="联系人">
            <s-input v-model="formValue.contactPeople" disabled allow-clear placeholder="联系人" />
          </s-form-item>
          <s-form-item label="联系人电话">
            <s-input
              v-model="formValue.contactPhone"
              disabled
              allow-clear
              placeholder="联系人电话"
            />
          </s-form-item>
          <s-form-item label="联系人邮箱">
            <s-input
              v-model="formValue.contactEmail"
              disabled
              allow-clear
              placeholder="联系人邮箱"
            />
          </s-form-item>
          <s-form-item label="排序号" name="orderNum">
            <s-input-number
              v-model="formValue.orderNum"
              disabled
              :min="1"
              :max="999"
              placeholder="排序号"
            />
          </s-form-item>
          <s-form-item label="创建人">
            <s-input v-model="formValue.createByAccount" disabled />
          </s-form-item>
          <s-form-item label="创建时间">
            <s-input v-model="formValue.createDate" disabled />
          </s-form-item>
          <s-form-item label="修改人">
            <s-input v-model="formValue.updateByAccount" disabled />
          </s-form-item>
          <s-form-item label="修改时间">
            <s-input v-model="formValue.updateDate" disabled />
          </s-form-item>
          <s-form-item label="简介" name="remark" size="big">
            <s-text-area v-model="formValue.deptDescribe" allow-clear placeholder="简介" />
          </s-form-item>
        </s-form>
      </s-scroll>
    </div>
  </s-modal>
</template>

<script>
export default {
  name: 'Detail',
  data() {
    return {
      formValue: {},
      visible: false
    }
  },
  methods: {
    open(id) {
      this.$loading(true)
      this.$api
        .GET('/realm/dept/selectOneById', { id: id })
        .then((res) => {
          if (!res.data) {
            this.$loading(false)
            this.visible = false
            this.$message.warn('数据不存在')
          } else {
            this.formValue = res.data
            this.$loading(false)
            this.visible = true
          }
        })
        .catch(() => {
          this.$loading(false)
        })
    }
  }
}
</script>

<style lang="less" scoped></style>
